home *** CD-ROM | disk | FTP | other *** search
- void ToolBoxInit(void);
- void MenuBarInit(void);
- void ResInit(void);
- void WindowInit(void);
- void EventLoop(void);
- void DoEvent(EventRecord *eventPtr);
- void HandleMouseDown(EventRecord *eventPtr);
- void HandleMenuChoice(long menuChoice);
- void DoUpdate(WindowPtr window);
- void CloseMeWindow(WindowPtr doomedWindow);
- void StrCopy(ConstStr255Param s1,Str255 s2);
- void DrawAntiAliasManString(ConstStr255Param s);
-
- WindowPtr gWindow;
-
- void main(void)
- {
- ToolBoxInit();
- MenuBarInit();
- WindowInit();
-
- EventLoop();
- }
-
- void ToolBoxInit(void)
- {
- InitGraf(&thePort);
- InitWindows();
- InitFonts();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
- }
-
- void MenuBarInit(void)
- {
- Handle menuBar;
- MenuHandle menu;
-
- menuBar=GetNewMBar(128);
- SetMenuBar(menuBar);
-
- menu=GetMHandle(128);
- AddResMenu(menu,'DRVR');
-
- DrawMenuBar();
- }
-
- void WindowInit(void)
- {
- Rect theRect;
-
- SetRect(&theRect,20,60,600,190);
- gWindow=NewCWindow(nil,&theRect,nil,true,0,(WindowPtr)-1L,true,(long)nil);
- SetPort(gWindow);
- }
-
- void EventLoop(void)
- {
- EventRecord event;
-
- while(1)
- {
- while(!WaitNextEvent(everyEvent,&event,20L,nil));
- DoEvent(&event);
- }
- }
-
- void DoEvent(EventRecord *eventPtr)
- {
- char theChar;
- WindowPtr window;
-
- switch(eventPtr->what)
- {
- case mouseDown:
- HandleMouseDown(eventPtr);
- break;
- case keyDown:
- case autoKey:
- theChar=eventPtr->message &charCodeMask;
- if(eventPtr->modifiers &cmdKey) HandleMenuChoice(MenuKey(theChar));
- break;
- case updateEvt:
- window=(WindowPtr)eventPtr->message;
- DoUpdate(window);
- break;
- }
- }
-
- void HandleMouseDown(EventRecord *eventPtr)
- {
- WindowPtr whichWindow;
- short thePart;
- long menuChoice;
- Point thePt;
-
- thePart=FindWindow(eventPtr->where,&whichWindow);
- switch(thePart)
- {
- case inMenuBar:
- menuChoice=MenuSelect(eventPtr->where);
- HandleMenuChoice(menuChoice);
- HiliteMenu(false);
- break;
- case inSysWindow:
- SystemClick(eventPtr,whichWindow);
- break;
- case inContent:
- SetPort(whichWindow);
- SelectWindow(whichWindow);
- thePt=eventPtr->where;
- GlobalToLocal(&thePt);
- break;
- case inDrag:
- DragWindow(whichWindow,eventPtr->where,&qd.screenBits.bounds);
- break;
- case inGoAway:
- if(TrackGoAway(whichWindow,eventPtr->where)) CloseMeWindow(whichWindow);
- break;
- }
- }
-
- void HandleMenuChoice(long menuChoice)
- {
- short menu,item;
- Str255 dAName;
- MenuHandle appleMenu;
- GrafPtr savePort;
-
- menu=HiWord(menuChoice);
- item=LoWord(menuChoice);
-
- switch(menu)
- {
- case 128:
- if(item==1);
- else
- {
- appleMenu=GetMHandle(128);
- GetPort(&savePort);
- GetItem(appleMenu,item,dAName);
- OpenDeskAcc(dAName);
- SetPort(savePort);
- }
- break;
- case 129:
- if(item==1) CloseMeWindow(FrontWindow());
- if(item==2) ExitToShell();
- break;
- case 130:
- break;
- }
- }
-
- void DoUpdate(WindowPtr window)
- {
- Rect theRect;
-
- BeginUpdate(window);
- if(window==gWindow)
- {
- SetPort(gWindow);
- BackColor(blackColor);
- EraseRect(&gWindow->portRect);
- ForeColor(blueColor);
- MoveTo(10,82);
- TextFace(0);
- TextFont(20);
- TextSize(72);
- DrawAAString("\pAntialiasing:");
- TextFont(4);
- DrawAAString("\pYeah!");
- MoveTo(10,116);
- TextSize(24);
- DrawAAString("\pBrought to you in part by Slackers, Inc.");
- }
- EndUpdate(window);
- }
-
- void CloseMeWindow(WindowPtr doomedWindow)
- {
- MenuHandle menu;
-
- CloseWindow(doomedWindow);
- DisposeGrafPort(doomedWindow);
- if(FrontWindow()==nil)
- {
- menu=GetMHandle(129);
- DisableItem(menu,1);
- }
- }
-
- void StrCopy(ConstStr255Param s1,Str255 s2)
- {
- short i;
-
- for(i=0;i<=s1[0];i++) s2[i]=s1[i];
- }